<template>
  <el-container>
    <el-header>
      <div class="sys-title">简书后台管理系统</div>
      <div class="header-right">
        <span @click="toHome">首页</span>
        <div><img :src="store.state.msg.avatar" alt="" /> </div><span>{{store.state.msg.username}}</span>
        <span @click="signOut">退出</span>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          :uniqueOpened="true"
          default-active="5"
          :router=true
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
        >
          <el-submenu index="/admin/users">
            <template #title>
              <i class="el-icon-user-solid"></i>
              <span>个人中心</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/admin/users/personal"
                >个人资料</el-menu-item
              >
              <el-menu-item index="/admin/users/password"
                >修改密码</el-menu-item
              >
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="/admin/article">
            <template #title>
              <i class="el-icon-menu"></i>
              <span>文章管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/admin/article/add">发布文章</el-menu-item>
              <el-menu-item index="/admin/article"
                >文章列表</el-menu-item
              >
            </el-menu-item-group>
          </el-submenu>

          <el-menu-item index="/admin/comment">
            <i class="el-icon-s-order"></i>
            <template #title>评论管理</template>
          </el-menu-item>

          <el-menu-item index="/admin/fans">
            <i class="el-icon-s-custom"></i>
            <template #title>粉丝管理</template>
          </el-menu-item>

          <el-menu-item index="/admin/star">
            <i class="el-icon-star-on"></i>
            <template #title>点赞管理</template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main><router-view></router-view></el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { useRouter } from "vue-router"
import { useStore } from "vuex"
const store = useStore()
const router = useRouter()
const signOut = () => {
  localStorage.removeItem("vuex")
  localStorage.removeItem("token")
  router.push({
    'name': "Login"
  })
}

const toHome = () => {
  router.push({name:"Web"})
}
</script>

<style lang="scss" scoped>
.el-header {
  background: #545c64;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .sys-title {
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
  }
  .header-right {
    display: flex;
    cursor: pointer;
    span {
      line-height: 40px;
      margin: 0 10px;
      &:hover {
        color: skyblue;
      }
    }
    div {
      overflow: hidden;
      border-radius: 50%;
      img {
        width: 40px;
        height: 40px;
      }
    }
  }
}
.el-aside {
  ul{
    height: 100%;
  }
}
.el-main {
  // background: red;
}
.el-container {
  height: 100%;
}
</style>